<?php  if (!defined('PATH_HD')) exit('No direct script access allowed');

class IndexControl extends Control{
    function __auto(){
        C("debug",0);
    }
    //后台主页
    function index(){
        $this->display(); 
    }
    //后台顶部
    function admin_top(){
    	$this->display();
    }
    //后台左侧视图
    function left(){
    	$this->display();
    }
    //后台右侧视图
    function right(){
    	$this->display();
    }
    //登陆页
    function login(){
        if(isset($_GET['logout'])){
            $this->display();
        }
        $this->display();
    }
    //获取验证码
    function getCode(){
        $code=new Code();
        $code->show();
    }
    //异步检测用户名是否存在
    function checkUser(){
         $user = $this->_post('username');
         $db = M('user');
         $result = $db->find("username='".$user."'");
         if(is_array($result)){
            echo json_encode(1);die;
         }else{
            echo json_encode(2);die;
         }
    }
    //处理用户登陆
    function userLogin(){
        $user = $this->_post('username');
        $ps = md5($this->_post('password'));
        $code = $this->_post('code');
        $db = M('user');
        $result = $db->find(array('username'=>$user,'password'=>$ps));
        if(is_array($result)){
            echo json_encode(1);die;
         }else{
            echo json_encode(2);die;
         }

    }
}
?>